import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Test1 {
    /**
     *目的:展示全文件名
     * 方法:使用递归
     */
    private static final List<String> list = new ArrayList<>();
    private static final List<File> listPlus = new ArrayList<>();
    private static void allShow(String path){
        File file = new File(path);
        if (file.isFile()){
            list.add(path);
        }else if (file.isDirectory()){
            String[] strings = file.list();
            assert strings != null;
            for (String s:strings) {
                allShow(path + "/" + s);
            }
        }else {

        }
    }
    private static void allShowPlus(File path){
        if (path.isFile()){
            listPlus.add(path);
        }else if (path.isDirectory()){
            File[] strings = path.listFiles();
            assert strings != null;
            for (File s:strings) {
                allShowPlus(s);
            }
        }else {

        }
    }
    public static void main(String[] args) throws InterruptedException, IOException {
      /*  allShow(".");
        for (String s:list) {
            System.out.println(s);
        }
       */
//        File file = new File("./HelloWord.txt");
//        file.createNewFile();
//        Thread.sleep(3000);
//        file.deleteOnExit();
//        System.out.println(file.getParent());
        File file = new File(".");
        List<File> files = new ArrayList<>();
        List<String> strings = new ArrayList<>();
        String[] strings1 = file.list();
        File[] files1 = file.listFiles();
        for (String s:strings1) {
            System.out.println(s);
        }
        System.out.println("==========");
        for (File s:files1) {
            System.out.println(s);
        }
        System.out.println("==========");
        allShow(".");
        for (String s:list) {
            System.out.println(s);
        }
        System.out.println("==========");
        File file1 = new File(".");
        allShowPlus(file1);
        for (File s:listPlus) {
            System.out.println(s);
        }
    }
}
